<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        联系我们
        <small>Control panel</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 控制台</a></li>
        <li class="active">管理员</li>
      </ol>
    </section>



    <!-- Main content -->
    <section class="content">

      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Advertising  Table</h3>

              <div class="box-tools">
                <button type="button" class="btn btn-info pull-right" data-toggle="modal" data-target="#myModal">
                  添加管理员
                </button>
              </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
              <form action="{:url('admin/adminuser/delall')}" method="post">
              <table class="table table-hover">
                <tbody><tr>
                  <th class="text-center" width="100"><input type="checkbox" value="" id="checkall" class=""> 全选</th>
                  <th>ID</th>
                  <th>图片</th>
                  <th>姓名</th>
                  <th>状态</th>
                  <th style="width: 20%">操作</th>
                </tr>

                <?php foreach($adminuser as $v): ?>
                <tr>
                  <td class="text-center"><input type="checkbox" value="<?php echo $v['ad_id']; ?>" name="idarr[]" class="cbox"></td>
                  <td><?php echo $v['ad_id']; ?></td>
                  <td><img src="<?php echo thumb($v['ad_img'], 150, 200); ?>" alt=""></td>
                  <td><?php echo $v['ad_name']; ?></td>
                  <td id="change_i"><?php
                  if($v['ad_isshow']==0){
                    echo '<i value="0" class="fa fa-circle text-green">    开启</i>';
                  }else{
                    echo '<i value="1" class="fa fa-circle text-red">    关闭</i>';
                  }
                  ?></td>
                  <td>
                    <a href="{:url('admin/adminuser/edit',['id' => $v['ad_id'] ])}"><button type="button" class="btn btn-sm btn-primary glyphicon glyphicon-pencil">  修改</button></a>
                    <a href="{:url('admin/adminuser/del',['id'=>$v['ad_id']])}"><button type="button" class="btn btn-sm btn-danger glyphicon glyphicon-trash">  删除</button></a>
                  </td>
                </tr>
                <?php endforeach; ?>
                </tbody></table>
              <div class="pull-left" style="margin: 20px;">
                <button type="submit" class="btn btn-default btn-gradient pull-right delall"><span class="glyphicon
glyphicon-trash"></span></button>
              </div>
              </form>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>


    </section>
    <!-- /.content -->
  </div>

<!-- Modal -->
<div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">


      <div class="row">
        <div class="col-md-12">
          <!-- Horizontal Form -->

          <div class="box-header with-border">
            <h3 class="box-title">添加管理员</h3>
          </div>
          <!-- /.box-header -->
          <!-- form start -->
          <form action="{:url('admin/adminuser/add')}" method="post"  enctype="multipart/form-data" class="form-horizontal">

            <div class="row text-center">
              <div class="col-lg-12" id="preview">
                <img id="imghead" border="0" src="__ADMINMY__/photo_icon.png" width="150" height="150" onclick="$('#previewImg').click();">
                <label for="" style="margin-right: 20px;">上传图片</label>
              </div>
              <input type="file" name="image" onchange="previewImage(this,300,250)" style="display: none;" id="previewImg">
            </div>

            <div class="box-body">
              <div class="form-group">
                <label for="name" class="col-sm-2 control-label">名称</label>

                <div class="col-sm-9">
                  <input type="text" class="form-control" name="ad_name" id="name" >
                  <p id="b_link_mes"  style="color: red;line-height: 34px;font-size: 12px;margin: 0;padding: 0;height: 12px;"></p>
                </div>
              </div>
              <div class="form-group">
                <label for="ad_password" class="col-sm-2 control-label">密码</label>

                <div class="col-sm-9">
                  <input type="password" class="form-control" name="ad_password" id="ad_password" >
                  <p id="v_name_mes"  style="color: red;line-height: 34px;font-size: 12px;margin: 0;padding: 0;height: 12px;"></p>
                </div>
              </div>
              <div class="form-group">
                <label for="che_password" class="col-sm-2 control-label">确认密码</label>

                <div class="col-sm-9">
                  <input type="password" class="form-control" name="che_password" id="che_password">
                  <p id="che_password_mes"  style="color: red;line-height: 34px;font-size: 12px;margin: 0;padding: 0;height: 12px;"></p>
                </div>
              </div>

              <div class="form-group">
                <label for="standard-list1" class="col-sm-2 control-label">是否开启</label>
                <div class="col-sm-9">
                  <select name="ad_isshow" id="standard-list1" class="form-control">
                    <option value="0">开启</option>
                    <option value="1">关闭</option>
                  </select>
                </div>
              </div>
            </div>




            <!-- /.box-body -->
            <div class="box-footer">
              <div class="col-sm-2">

              </div>

              <div class="col-sm-9">
                <button type="submit" class="btn btn-info pull-right">提交</button>
              </div>

            </div>
            <!-- /.box-footer -->
          </form>

          <!-- /.box -->
        </div>
        <!--/.col (right) -->
      </div>

    </div>
  </div>
</div>

<script>

//  $("#change_i i").click(function () {
//      var i_val = $(this).val();
//      console.log(i_val);
//      alert(i_val);
//      $.ajax({
//          url : "{:url('admin/adminuser/chang_ini')}",
//          data : {
//              "ad_name" : ad_name
//          },
//          type : "post",
//          success : function(data) {
//              console.log(data.mes);
//              if (data.mes == 2) {
//                  $("#b_link_mes").html('*用户已存在');
//              }
//          }
//      });
//  });

    $("#name").blur(function(){
        if($(this).val()==0){
            $("#b_link_mes").html('*请填写名称');
            return false;
        }
        var ad_name = $(this).val();
        $.ajax({
            url : "{:url('admin/adminuser/check')}",
            data : {
                "ad_name" : ad_name
            },
            type : "post",
            success : function(data) {
                console.log(data.mes);
                if (data.mes == 2) {
                    $("#b_link_mes").html('*用户已存在');
                }
            }
        });

    });
    $("#name").focus(function(){
        $("#b_link_mes").html('');
    });

    $("#ad_password").blur(function(){
        if($(this).val()==0){
            $("#v_name_mes").html('*请填密码');
            return false;
        }

    });
    $("#ad_password").focus(function(){
        $("#v_name_mes").html('');
    });

    $("#che_password").blur(function(){
        if($(this).val()==0){
            $("#che_password_mes").html('*请填确认密码');
            return false;
        }

    });
    $("#che_password").focus(function(){
        $("#che_password_mes").html('');
    });



</script>